home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ussbc23.zip / DEMOS / DEMOFRM.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-15  |  3KB  |  132 lines

  1. unit Demofrm;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, Spin, Ssbc, ExtCtrls, Printers;
  8.  
  9. type
  10.   TfmDemo = class(TForm)
  11.     ssBarCode: TssBarCode;
  12.     Panel: TPanel;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     Label4: TLabel;
  17.     cbType: TComboBox;
  18.     ckBearer: TCheckBox;
  19.     ckReadable: TCheckBox;
  20.     cbOrientation: TComboBox;
  21.     edData: TEdit;
  22.     btUpdate: TBitBtn;
  23.     btClose: TBitBtn;
  24.     Panel1: TPanel;
  25.     edWidth: TEdit;
  26.     Label5: TLabel;
  27.     btPrint: TBitBtn;
  28.     FontDialog: TFontDialog;
  29.     btFont: TBitBtn;
  30.     procedure btUpdateClick(Sender: TObject);
  31.     procedure FormCreate(Sender: TObject);
  32.     procedure ckBearerClick(Sender: TObject);
  33.     procedure ckReadableClick(Sender: TObject);
  34.     procedure FormResize(Sender: TObject);
  35.     procedure btPrintClick(Sender: TObject);
  36.     procedure btFontClick(Sender: TObject);
  37.   private
  38.     procedure RepositionCode;
  39.   public
  40.   end;
  41.  
  42. var
  43.   fmDemo: TfmDemo;
  44.  
  45. implementation
  46.  
  47. {$R *.DFM}
  48.  
  49. procedure TfmDemo.btUpdateClick(Sender: TObject);
  50. begin
  51.   with ssBarCode do
  52.   begin
  53.     Data := edData.Text;
  54.     BarWidth := StrToFloat(edWidth.Text);
  55.     case cbType.ItemIndex of
  56.       0 : BarCodeType := bcCode128;
  57.       1 : BarCodeType := bcCode39;
  58.       2 : BarCodeType := bcEAN_13;
  59.       3 : BarCodeType := bcInt2of5;
  60.       4 : BarCodeType := bcPostnet;
  61.       5 : BarCodeType := bcUPC_A;
  62.     end;
  63.     case cbOrientation.ItemIndex of
  64.       0 : Orientation := orLeft_Right;
  65.       1 : Orientation := orRight_Left;
  66.       2 : Orientation := orTop_Bottom;
  67.       3 : Orientation := orBottom_Top;
  68.     end;
  69.     ckBearer.Checked := BearerBars;
  70.   end;
  71.   RepositionCode;
  72. end;
  73.  
  74. procedure TfmDemo.FormCreate(Sender: TObject);
  75. begin
  76.   cbType.ItemIndex := 1;
  77.   cbOrientation.ItemIndex := 0;
  78.   RepositionCode;
  79. end;
  80.  
  81. procedure TfmDemo.ckBearerClick(Sender: TObject);
  82. begin
  83.   try
  84.     ssBarCode.BearerBars := ckBearer.Checked;
  85.   finally
  86.     ckBearer.Checked := ssBarCode.BearerBars;
  87.   end;
  88. end;
  89.  
  90. procedure TfmDemo.ckReadableClick(Sender: TObject);
  91. begin
  92.   ssBarCode.PrintHumanReadable := ckReadable.Checked;
  93. end;
  94.  
  95. procedure TfmDemo.RepositionCode;
  96.  
  97. begin
  98.   ssBarCode.Left := (fmDemo.Width - ssBarCode.Width) div 2;
  99.   ssBarCode.Top := ((fmDemo.Height-Panel.Height) - ssBarCode.Height) div 2;
  100. end;
  101.  
  102. procedure TfmDemo.FormResize(Sender: TObject);
  103. begin
  104.   RepositionCode;
  105. end;
  106.  
  107. procedure TfmDemo.btPrintClick(Sender: TObject);
  108. begin
  109.   with Printer do
  110.   begin
  111.     BeginDoc;
  112.     { It's this easy to print your barcode!  Specify the X and Y positions in inches.
  113.       The third parameter is the height in inches.  If you specify 0 (zero), ssBarcode will
  114.       calculate the standard height-to-width ratio for this code }
  115.  
  116.     ssBarCode.PrintBarcode(1.0,1.0,0);
  117.     EndDoc;
  118.   end;
  119. end;
  120.  
  121. procedure TfmDemo.btFontClick(Sender: TObject);
  122. begin
  123.   with FontDialog do
  124.   begin
  125.     Font := ssBarcode.Font;
  126.     if Execute then
  127.       ssBarcode.Font := Font;
  128.   end;
  129. end;
  130.  
  131. end.
  132.